package com.zhangshitong.controller;

import java.util.Map;

import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhangshitong.common.ApplicationContextHelper;
import com.zhangshitong.common.JsonData;
import com.zhangshitong.dao.SysAclMapper;
import com.zhangshitong.dao.SysAclModuleMapper;
import com.zhangshitong.exception.ParamException;
import com.zhangshitong.exception.PermissionException;
import com.zhangshitong.model.SysAclModule;
import com.zhangshitong.param.TestVo;
import com.zhangshitong.util.BeanValidator;
import com.zhangshitong.util.JsonMapper;

@Controller
@RequestMapping(value="/test")
@Slf4j
public class TestController {

	@RequestMapping(value="/hello.json")
	@ResponseBody
	public JsonData sayHello(){
		log.info("hello");
		throw new RuntimeException("text message");
		//return JsonData.success("hello test");
	}
	
	
	@RequestMapping(value="/validate.json")
	@ResponseBody
	public JsonData validate(TestVo vo) throws ParamException{
		log.info("validate");
		
		SysAclMapper moduleMapper = ApplicationContextHelper.popBean(SysAclMapper.class);
	    //SysAclModule module = moduleMapper.selectByPrimaryKey(1);
	    //log.info(JsonMapper.obj2String(module));
		BeanValidator.check(vo);
		return JsonData.success("success validate");
	}
}
